home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 014 / pdterm / serial.c < prev    next >
C/C++ Source or Header  |  1995-03-17  |  3KB  |  79 lines

  1. #include "term.h"
  2.  
  3. /* Open a serial device */
  4.       int
  5. OpenSerial(readrequest,writerequest)
  6.       struct IOExtSer *readrequest;
  7.       struct IOExtSer *writerequest;
  8.       {
  9.             int error;
  10.             readrequest->io_SerFlags = NULL;
  11.             error = OpenDevice(SERIALNAME, NULL, readrequest, NULL);
  12.             writerequest->IOSer.io_Device = readrequest->IOSer.io_Device;
  13.             writerequest->IOSer.io_Unit = readrequest->IOSer.io_Unit;
  14.             writerequest->io_CtlChar = readrequest->io_CtlChar;
  15.             writerequest->io_ReadLen = readrequest->io_ReadLen;
  16.             writerequest->io_BrkTime = readrequest->io_BrkTime;
  17.             writerequest->io_Baud = readrequest->io_Baud;
  18.             writerequest->io_WriteLen = readrequest->io_WriteLen;
  19.             writerequest->io_StopBits = readrequest->io_StopBits;
  20.             writerequest->io_RBufLen = readrequest->io_RBufLen;
  21.             writerequest->io_SerFlags = readrequest->io_SerFlags;
  22.             writerequest->io_TermArray.TermArray0
  23.             = readrequest->io_TermArray.TermArray0;
  24.             writerequest->io_TermArray.TermArray1
  25.             = readrequest->io_TermArray.TermArray1;
  26.             /* clone required parts of the request */
  27.             return(error);
  28.       }
  29.  
  30.       int
  31. SerPutChar(request,character)
  32.       struct IOExtSer *request;
  33.       char character;
  34.       {
  35.             request->IOSer.io_Command = CMD_WRITE;
  36.             request->IOSer.io_Data = (APTR)&character;
  37.             request->IOSer.io_Length = 1;
  38.             DoIO(request);
  39.             return(0);
  40.       }
  41.  
  42.       int
  43. QueueSerRead(request, whereto)
  44.       struct IOExtSer *request;
  45.       char *whereto;
  46.       {
  47.             request->IOSer.io_Command = CMD_READ;
  48.             request->IOSer.io_Data = (APTR)whereto;
  49.             request->IOSer.io_Length = 1;
  50.             SendIO(request);
  51.             return(0);
  52.       }
  53.  
  54.    int
  55. SetParams(io,rbuf_len,rlen,wlen,brk,baud,sf,ta0,ta1)
  56.    struct IOExtSer *io;
  57.    unsigned long rbuf_len;
  58.    unsigned char rlen;
  59.    unsigned char wlen;
  60.    unsigned long brk;
  61.    unsigned long baud;
  62.    unsigned char sf;
  63.    unsigned long ta0;
  64.    unsigned long ta1;
  65.    {
  66.       io->io_ReadLen = rlen;
  67.       io->io_WriteLen = wlen;
  68.       io->io_Baud = baud;
  69.       io->io_BrkTime = brk;
  70.       io->io_StopBits = 0x01;
  71.       io->io_RBufLen = rbuf_len;
  72.       io->io_SerFlags = sf;
  73.       io->io_TermArray.TermArray0 = ta0;
  74.       io->io_TermArray.TermArray1 = ta1;
  75.       io->IOSer.io_Command = SDCMD_SETPARAMS;
  76.    
  77.       return(DoIO(io));
  78. }
  79.